Fix claude-code installing files owned by root#229
Conversation
ec18a5b to
a135a54
Compare
koralowiec
left a comment
There was a problem hiding this comment.
Hi, please bump the feature version from 2.0.1 to 2.0.2
`bootstrap.sh` was running as root, so `~/.claude/`, `~/.local/bin/claude`, and `~/.local/share/claude/` all ended up under `/root/` owned by root. The devcontainer user had no access to config or shell integration. Use the devcontainer spec variables `_REMOTE_USER` and `_REMOTE_USER_HOME` to run the install as the devcontainer user, following the pattern used by `asdf-package`, `homebrew-package`, and other features in this repo.
a135a54 to
5962aef
Compare
|
@koralowiec Done. |
| # It's installed in /root/.local/bin/claude and there's no option to override the install location | ||
| cp "$HOME/.local/bin/claude" /usr/local/bin/claude | ||
| # It's installed in ~/.local/bin/claude and there's no option to override the install location | ||
| cp "$_REMOTE_USER_HOME/.local/bin/claude" /usr/local/bin/claude |
There was a problem hiding this comment.
Question: _REMOTE_USER_HOME empty in certain setups?
Hi @brianhelba — after this PR landed, I'm seeing a build failure on line 20:
cp: cannot stat '/.local/bin/claude': No such file or directory
ERROR: Feature "claude-code" failed to install!
The su - "$_REMOTE_USER" step works fine (Claude installs successfully to the user's home), but the subsequent cp resolves to /.local/bin/claude — suggesting
_REMOTE_USER_HOME is empty in my build context.
My setup uses a custom base image (Ubuntu 24.04/CUDA) with common-utils creating the user and "remoteUser": "${localEnv:USER}" in the devcontainer config. Pinning
back to v2.0.0 resolves the issue.
Is _REMOTE_USER_HOME expected to always be available at this point in the feature lifecycle? Or would it be safer to fall back to resolving the home directory from
passwd, e.g.:
: "${_REMOTE_USER_HOME:=$(eval echo ~"$_REMOTE_USER")}"
cp "$_REMOTE_USER_HOME/.local/bin/claude" /usr/local/bin/claude
|
According to the dev container spec, the @ZhiliangWu I think it's reasonable to add a fallback. I'll be happy to review a PR if you want to make one. |
bootstrap.shwas running as root, so~/.claude/,~/.local/bin/claude, and~/.local/share/claude/all ended up under/root/owned by root. The devcontainer user had no access to config or shell integration.Use the devcontainer spec variables
_REMOTE_USERand_REMOTE_USER_HOMEto run the install as the devcontainer user, following the pattern used byasdf-package,homebrew-package, and other features in this repo.